window.onload = function(){
	var obj = document.getElementById("wrap");
	obj.onmouseover = function(){
		startMove(this,400);
	}
	obj.onmouseout = function(){
		startMove(this,200);
	}
}

var timer = null;
function startMove(elem,final){
	clearInterval(timer);
	var obj = document.getElementById("wrap");
	var speed = 0;
	timer = setInterval(function(){
		if(obj.offsetWidth == final){
			clearInterval(timer);
		}else{
			speed = (final - obj.offsetWidth)/5;
			speed = speed > 0 ? Math.ceil(speed):Math.floor(speed);
			obj.style.width = parseInt(getStyle(obj,'width')) + speed + "px";
		}
	},30)
}


//获取元素样式
function getStyle(obj,attr){         
	if(obj.currentStyle){
		return obj.currentStyle[attr];
	}else{
		return getComputedStyle(obj,false)[attr];
	}
}